package org.dq.like.task;

import lombok.extern.slf4j.Slf4j;
import org.dq.like.controller.JuejinLikeController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * 定时任务
 * 定时刷新沸点列表进行点赞
 *
 * @author klh
 * @date 2023/09/07 18:05:14
 */
@Slf4j
@Service
@EnableScheduling
public class AutoTask {

    @Autowired
    private JuejinLikeController juejinLikeController;

    /**
     * 每十分钟执行一次
     */
    @Scheduled(cron = "0 0/10 * * * ?")
    public void task() {
        log.info("定时点赞任务执行开始");
        try {
            juejinLikeController.likeBoil(true, false);
        } catch (Exception e) {
            log.error("定时点赞任务异常", e);
        }
        log.info("定时点赞任务执行结束");
    }

}
